@echo off
setlocal enabledelayedexpansion

echo.
echo ========================================
echo Flink WordCount Learning Project
echo ========================================
echo.

where mvn >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo Error: Maven not found. Please install Maven and add it to PATH.
    pause
    exit /b 1
)

where java >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo Error: Java not found. Please install Java 17 or higher.
    pause
    exit /b 1
)

echo Select a program to run:
echo 1. Batch version - WordCount (recommended)
echo 2. Streaming version - StreamingWordCount
echo 3. Build project (do not run)
echo 4. Clean build (mvn clean)
echo 5. Exit
echo.

set /p choice="Enter your choice (1-5): "

if "%choice%"=="1" (
    echo.
    echo Running batch version...
    mvn exec:java -Dexec.mainClass="com.example.WordCount" -Dexec.jvmArgs="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
) else if "%choice%"=="2" (
    echo.
    echo Running streaming version...
    mvn exec:java -Dexec.mainClass="com.example.StreamingWordCount" -Dexec.jvmArgs="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
) else if "%choice%"=="3" (
    echo.
    echo Building project...
    mvn clean install
) else if "%choice%"=="4" (
    echo.
    echo Cleaning build...
    mvn clean
) else if "%choice%"=="5" (
    exit /b 0
) else (
    echo Invalid choice. Please try again.
)

echo.
pause
endlocal
